<template>
  <el-container class="home-container">
    <!-- 头部区域-->
    <el-header>
      <div>
        <img src="../assets/logo.png" alt="" sizes="15px">
        <span>润和云盘</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <!--  主页面主体区  -->
    <el-container>
      <!-- 侧边栏-->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <!--侧边栏菜单区-->
        <el-menu background-color=cornflowerblue text-color="#fff" active-text-color="#ffd04b"
                 unique-opened :collapse="isCollapse" :collapse-transition="false" router>
          <!--一级菜单-->
          <el-submenu index="1">
            <template slot="title">
              <!-- 图标-->
              <i class="el-icon-location"></i>
              <!-- 文本-->
              <span>我的网盘</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="/folders">
              <i class="el-icon-folder"></i>
              <span>我的文件</span>
            </el-menu-item>
            <el-menu-item index="/share_files">
              <i class="el-icon-share"></i>
              <span>我的分享</span>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="2">
            <template slot="title">
              <!-- 图标-->
              <i class="el-icon-user-solid"></i>
              <!-- 文本-->
              <span>好友管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="friends">
              <i class="el-icon-user"></i>
              <span>我的好友</span>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <!-- 图标-->
              <i class="el-icon-star-on"></i>
              <!-- 文本-->
              <span>收藏管理</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="collections">
              <i class="el-icon-star-off"></i>
              <span>我的收藏</span>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <!-- 图标-->
              <i class="el-icon-delete-solid"></i>
              <!-- 文本-->
              <span>回收站</span>
            </template>
            <!--二级菜单-->
            <el-menu-item index="rubbish">
              <i class="el-icon-delete"></i>
              <span>我的回收站</span>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 主要内容 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data () {
    return {
      isCollapse: false
    }
  },
  name: 'home.vue',
  methods: {
    logout () {
      this.$router.push('/login')
    },
    // 点击按钮实现菜单的折叠
    toggleCollapse () {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style Lang="less" scoped>
.home-container{
  height: 100%;
}
.el-header{
  background-color: cornflowerblue;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: aliceblue;
  font-size: 20px;
}
.el-header div{
  display: flex;
  align-items: center;
}

.el-header span{
  margin-left: 15px;
}

.el-aside{
  background-color: cornflowerblue;
}
.el-menu{
  border-right: none;
}
.el-main{
  background-color: aliceblue;
}
.toggle-button{
  background-color: cornflowerblue;
  font-size: 10px;
  line-height: 24px;
  color: aliceblue;
  text-align: center;
  letter-spacing: 0.2em;
  cursor: pointer;
}

</style>
